﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;

namespace BattleTank3D.Telas
{
    class Introducao
    {
        /// <summary>
        /// Objeto contendo o video de introdução do jogo
        /// </summary>
        public Video videoIntro;

        /// <summary>
        /// Objeto utilizado para apresentar o video
        /// </summary>
        public VideoPlayer mediaPlayer = new VideoPlayer();


        /// <summary>
        /// Fonte do texto utilizad na introdução
        /// </summary>
        SpriteFont fonteIntroducao;

        
       
        public void LoadContent(ContentManager Content)
        {
            videoIntro = Content.Load<Video>("Videos/exemplo");
            fonteIntroducao = Content.Load<SpriteFont>("Fonts/introducaoFont");
        }

        public void Update(GameTime gameTime, KeyboardState keyboard, KeyboardState oldKeyboard)
        {


            if ((mediaPlayer.State == MediaState.Stopped))
            {
                mediaPlayer.Play(videoIntro);

            }

            if ((keyboard.IsKeyDown(Keys.Space) && (!oldKeyboard.IsKeyDown(Keys.Space))))
            {
                mediaPlayer.Stop();
            }

        }

        public void Draw(GameTime gameTime, Viewport viewport,SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(mediaPlayer.GetTexture(), new Rectangle(0, 0, viewport.Width, viewport.Height), Color.White);
            spriteBatch.DrawString(this.fonteIntroducao, "Pressione <ESPAÇO> para ir ao Menu...", new Vector2(100, viewport.Height - 50), Color.White);
            spriteBatch.End();
        }
    }
}
